import { Router } from 'express'
import auth from '../middlewares/auth'
import userRouter from './users'
import employeeRouter from './employee'
import projectManagerRouter from './projectManager'
import projectRouter from './project'
import projectEmployeeLinkRouter from './projectEmployeeLink'
import projectManagerLinkRouter from './projectManagerLink'

import { createUser, login } from '../controllers/users'
import { createUserValidator, loginValidator } from '../middlewares/validation'
import NotFound from '../errors/NotFoundError'

const router = Router()
router.post('/signin', loginValidator, login)
router.post('/signup', createUserValidator, createUser)

router.use('/users', auth, userRouter)
router.use('/employee', auth, employeeRouter)
router.use('/projectManager', auth, projectManagerRouter)
router.use('/project', auth, projectRouter)
router.use('/projectEmployeeLink', auth, projectEmployeeLinkRouter)
router.use('/projectManagerLink', auth, projectManagerLinkRouter)
// router.use('/todo', auth, todoRouter)

router.use('*', auth, (req, res, next) => {
  next(new NotFound('Страница не найдена'))
})

export default router
